package com.yikome.purchase.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.yikome.common.CommonRepository;
import com.yikome.purchase.entity.PurchaseProduct;

@Repository
public interface PurchaseProductRepository extends CommonRepository<PurchaseProduct, Long> {

	@Query("select t from PurchaseProduct t where t.yn = 1 and t.purchaseCode = :purchaseCode order by t.productSkuBarcode")
	List<PurchaseProduct> findPurchaseProduct(@Param("purchaseCode")String purchaseCode);
	
	@Query("select t from PurchaseProduct t where t.yn = 1 and t.purchaseCode = :purchaseCode and t.productSkuBarcode = :productSkuBarcode order by t.productSkuBarcode")
	PurchaseProduct findPurchaseProduct(@Param("purchaseCode")String purchaseCode , @Param("productSkuBarcode")String productSkuBarcode);

	@Query("select t from PurchaseProduct t where t.yn = 1 and t.id = :purchaseProductId")
	PurchaseProduct findPurchaseProduct(@Param("purchaseProductId")Long purchaseProductId);

}
